package com.tubang.logistics.util;

import org.apache.poi.hssf.usermodel.*;
import org.apache.poi.ss.usermodel.VerticalAlignment;

public class ExcelUtils {

	public static HSSFWorkbook createMoreSheetHSSFWorkbook(String[][]... excelSheet) {
		HSSFWorkbook workbook = new HSSFWorkbook();
		for (String[][] excelContent : excelSheet) {
			HSSFSheet sheet = workbook.createSheet();
			//workbook.setSheetName(sheetNum, sheetTitle);
			HSSFCellStyle cellStyle = workbook.createCellStyle();
			HSSFFont headFont = workbook.createFont();
			headFont.setBold(true);
			cellStyle.setFont(headFont);
			cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);

			for (int i = 0; i < excelContent.length; i++) {
				HSSFRow row = sheet.createRow(i);
				for (int j = 0; j < excelContent[i].length; j++) {
					HSSFCell cell = row.createCell(j);
					if (i == 0) {
						row.setHeight((short) 600);
						cell.setCellStyle(cellStyle);
					}
					//sheet.autoSizeColumn(j);
					cell.setCellValue(excelContent[i][j]);
				}
			}
		}

		return workbook;
	}
}
